home *** CD-ROM | disk | FTP | other *** search
- Path: menkar.cs.utk.edu!doolin
- From: doolin@menkar.cs.utk.edu (David Doolin)
- Newsgroups: comp.lang.c
- Subject: Re: GNU C & pow(x,y)
- Date: 28 Feb 1996 23:16:19 GMT
- Organization: Computer Science Dept, University of Tennessee, Knoxville
- Distribution: world
- Message-ID: <4h2no3INN2sm@CS.UTK.EDU>
- References: <9602162139036@br-ranch.org> <4gq1o5$386@SNFC21_SRVR_WWW.PBI.net>
- NNTP-Posting-Host: menkar.cs.utk.edu
-
- In article <4gq1o5$386@SNFC21_SRVR_WWW.PBI.net>, mich@pbinet.com writes:
- |> In <9602162139036@br-ranch.org>, robert.threet@br-ranch.org (Robert Threet) writes:
- |> >I've tried using 1/x instead of the negative exponent, but I don't
- |> >think that's my problem. Here's the line:
- |>
- |> > paymnt = pow((amt * mo_rate)/(1-(1 + mo_rate)), (-mo_rate));
- |>
- |> >All variables are defined as floating point. I've included
- |> >"math.h" and I use this to compile:
- |>
- |> > gcc -o mort mort.c -lm
- |>
- |> >Despite this I keep getting the error: "undefined ref. to pow".
- |>
- |> >Can someone...
- |>
- |> >A) Tell me what I'm doing wrong... or
- |> >B) Give me a better formula for calculating a mortgage payment?
- |>
- |> I don't think your formula is the problem. Don't you need to explicately name the
- |> object file on the command line for GCC? Also, you might make sure you're using
- |> function prototypes.
- |>
-
-
- Yeah, yeah. Look at the man page:
-
-
- EXP(3M) MATHEMATICAL LIBRARY EXP(3M)
-
-
-
- NAME
- exp, expm1, exp2, exp10, log, log1p, log2, log10, pow, com-
- pound, annuity - exponential, logarithm, power
-
- SYNOPSIS
- #include <math.h>
-
- ...
-
- double pow(double x, double y);
- ^^^^^^
- ...
-
-
- This silly stuff happens to me all the time.
- ROT (rule of thumb): If you use <math.h>, declare
- all would-be floats as doubles. Unless your code
- is way huge, or it consists of calling that routine
- ad infinitum, you probably won't notice the speed
- difference in execution over floats.
-
- Ciao,
- Dave Doolin
-